﻿using System.Collections.Generic;

namespace Nx.UI.Navigation
{
    public abstract class BaseNavigationArgument : INavigationArgument
    {
        public BaseNavigationArgument(object argument)
        {
            _Argument = argument;
        }

        private object _Argument;

        /// <summary>
        /// Gets the target and casts it to the target platform
        /// </summary>
        /// <typeparam name="T">Use System.object on WinRT or Dictionary&lt;string, string&gt; on Silverlight/Windows Phone</typeparam>
        /// <returns>The navigation target consumable by the internal NavigationFrame</returns>
        public T GetArgument<T>()
        {
            return (T)_Argument;
        }

        //public static implicit operator object(BaseNavigationArgument argument)
        //{
        //    return argument.GetArgument<object>();
        //}

        public static implicit operator Dictionary<string, string>(BaseNavigationArgument argument)
        {
            return argument.GetArgument<Dictionary<string, string>>();
        }
    }

    public abstract class BaseNavigationArgument<T> : BaseNavigationArgument
    {
        public BaseNavigationArgument(T target)
            : base(target)
        {
        }

        internal T GetArgument()
        {
            return base.GetArgument<T>();
        }
    }
}
